package com.unittec.drainage.provider.manage.service;

import com.unittec.drainage.sdk.manage.request.*;
import com.unittec.drainage.sdk.root.internal.exception.BusinessException;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class HomePageService {

    /**
     * 8个数据统计（左一）
     * @param req301200
     * @return
     */
    public Object getEightSum(Req301200 req301200) {
        /**
         * total_users 用户总数
         * total_water_volume 本年总用水量
         * total_sewage_charge 本年总污水费
         * total_sewage_charge_receipts 本年实收污水费
         * arrearage_warning_reminder 欠费预警提醒
         * total_sewage_charge_arrears 欠收污水费
         * total_sewage_charge_receivable_self 本年自备水源应收
         * total_sewage_charge_receivable_construction 本年建筑施工应收
         */
        HashMap<String, BigDecimal> rs = new HashMap<>();
        rs.put("total_users",new BigDecimal("349565").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_water_volume",new BigDecimal("545453345").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_sewage_charge",new BigDecimal("65454527").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_sewage_charge_receipts",new BigDecimal("45459841").setScale(0,BigDecimal.ROUND_UP));
        rs.put("arrearage_warning_reminder",new BigDecimal("13").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_sewage_charge_arrears",new BigDecimal("4524").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_sewage_charge_receivable_self",new BigDecimal("25755787").setScale(0,BigDecimal.ROUND_UP));
        rs.put("total_sewage_charge_receivable_construction",new BigDecimal("27851745").setScale(0,BigDecimal.ROUND_UP));
        return rs;
    }

    /**
     * 本年水系水量统计
     * @param req301201
     * @return
     */
    public Object getWaterVolumeOfWaterSystem(Req301201 req301201) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();
        HashMap<String, Object> d1 = new HashMap<>();
        d1.put("river_name","磁湖水系");
        d1.put("water_consumption",new BigDecimal("150").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d1);
        HashMap<String, Object> d2 = new HashMap<>();
        d2.put("river_name","河西水系");
        d2.put("water_consumption",new BigDecimal("124").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d2);
        HashMap<String, Object> d3 = new HashMap<>();
        d3.put("river_name","花湖水系");
        d3.put("water_consumption",new BigDecimal("133").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d3);
        HashMap<String, Object> d4 = new HashMap<>();
        d4.put("river_name","黄金山水系");
        d4.put("water_consumption",new BigDecimal("50").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d4);
        HashMap<String, Object> d5 = new HashMap<>();
        d5.put("river_name","青山湖水系");
        d5.put("water_consumption",new BigDecimal("180").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d5);
        HashMap<String, Object> d6 = new HashMap<>();
        d6.put("river_name","铁山水系");
        d6.put("water_consumption",new BigDecimal("110").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d6);
        HashMap<String, Object> d7 = new HashMap<>();
        d7.put("river_name","团城山水系");
        d7.put("water_consumption",new BigDecimal("100").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d7);
        HashMap<String, Object> d8 = new HashMap<>();
        d8.put("river_name","新下陆水系");
        d8.put("water_consumption",new BigDecimal("30").setScale(0,BigDecimal.ROUND_UP));
        rs.add(d8);
        return rs;
    }

    /**
     * 本年各月用水量曲线
     * @param req301202
     * @return
     */
    public Object getWaterConsumptionCurve(Req301202 req301202) {
        HashMap<String, Object> rs1 = new HashMap<>();
        rs1.put("water_consumption",new BigDecimal("150").setScale(0,BigDecimal.ROUND_UP));
        rs1.put("month","1");

        HashMap<String, Object> rs2 = new HashMap<>();
        rs2.put("water_consumption",new BigDecimal("124").setScale(0,BigDecimal.ROUND_UP));
        rs2.put("month","2");

        HashMap<String, Object> rs3 = new HashMap<>();
        rs3.put("water_consumption",new BigDecimal("133").setScale(0,BigDecimal.ROUND_UP));
        rs3.put("month","3");

        HashMap<String, Object> rs4 = new HashMap<>();
        rs4.put("water_consumption",new BigDecimal("50").setScale(0,BigDecimal.ROUND_UP));
        rs4.put("month","4");

        HashMap<String, Object> rs5 = new HashMap<>();
        rs5.put("water_consumption",new BigDecimal("180").setScale(0,BigDecimal.ROUND_UP));
        rs5.put("month","5");

        HashMap<String, Object> rs6 = new HashMap<>();
        rs6.put("water_consumption",new BigDecimal("110").setScale(0,BigDecimal.ROUND_UP));
        rs6.put("month","6");

        HashMap<String, Object> rs7 = new HashMap<>();
        rs7.put("water_consumption",new BigDecimal("100").setScale(0,BigDecimal.ROUND_UP));
        rs7.put("month","7");

        HashMap<String, Object> rs8 = new HashMap<>();
        rs8.put("water_consumption",new BigDecimal("130").setScale(0,BigDecimal.ROUND_UP));
        rs8.put("month","8");

        HashMap<String, Object> rs9 = new HashMap<>();
        rs9.put("water_consumption",new BigDecimal("90").setScale(0,BigDecimal.ROUND_UP));
        rs9.put("month","9");

        HashMap<String, Object> rs10 = new HashMap<>();
        rs10.put("water_consumption",new BigDecimal("70").setScale(0,BigDecimal.ROUND_UP));
        rs10.put("month","10");

        HashMap<String, Object> rs11 = new HashMap<>();
        rs11.put("water_consumption",new BigDecimal("60").setScale(0,BigDecimal.ROUND_UP));
        rs11.put("month","11");

        HashMap<String, Object> rs12 = new HashMap<>();
        rs12.put("water_consumption",new BigDecimal("70").setScale(0,BigDecimal.ROUND_UP));
        rs12.put("month","12");

        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();
        rs.add(rs1);
        rs.add(rs2);
        rs.add(rs3);
        rs.add(rs4);
        rs.add(rs5);
        rs.add(rs6);
        rs.add(rs7);
        rs.add(rs8);
        rs.add(rs9);
        rs.add(rs10);
        rs.add(rs11);
        rs.add(rs12);
        return rs;
    }

    /**
     * 本年排行
     * @param req301203
     * @return
     */
    public Object getAnnualRanking(Req301203 req301203) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();
        switch (req301203.getType()){
            case "1" ://应收
                HashMap<String, Object> user1 = new HashMap<>();
                user1.put("user_code","ZB10010");
                user1.put("user_name","花湖建筑公司");
                user1.put("sewage_charge_receivable",new BigDecimal("6249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user2 = new HashMap<>();
                user2.put("user_code","JZ20010");
                user2.put("user_name","黄石市纺织公司");
                user2.put("sewage_charge_receivable",new BigDecimal("5249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user3 = new HashMap<>();
                user3.put("user_code","ZB30410");
                user3.put("user_name","花湖农场");
                user3.put("sewage_charge_receivable",new BigDecimal("4240072").setScale(0,BigDecimal.ROUND_UP));
                rs.add(user1);
                rs.add(user2);
                rs.add(user3);
                break;
            case "2" ://实收
                HashMap<String, Object> user21 = new HashMap<>();
                user21.put("user_code","ZB10010");
                user21.put("user_name","花湖建筑公司");
                user21.put("sewage_charge_receivable",new BigDecimal("6249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user22 = new HashMap<>();
                user22.put("user_code","JZ20010");
                user22.put("user_name","黄石市纺织公司");
                user22.put("sewage_charge_receivable",new BigDecimal("5249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user23 = new HashMap<>();
                user23.put("user_code","ZB30410");
                user23.put("user_name","花湖农场");
                user23.put("sewage_charge_receivable",new BigDecimal("9240072").setScale(0,BigDecimal.ROUND_UP));
                rs.add(user23);
                rs.add(user21);
                rs.add(user22);
                break;
            case "3" ://欠费
                HashMap<String, Object> user31 = new HashMap<>();
                user31.put("user_code","ZB10010");
                user31.put("user_name","花湖建筑公司");
                user31.put("sewage_charge_receivable",new BigDecimal("2249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user32 = new HashMap<>();
                user32.put("user_code","JZ20010");
                user32.put("user_name","黄石市纺织公司");
                user32.put("sewage_charge_receivable",new BigDecimal("5249872").setScale(0,BigDecimal.ROUND_UP));
                HashMap<String, Object> user33 = new HashMap<>();
                user33.put("user_code","ZB30410");
                user33.put("user_name","花湖农场");
                user33.put("sewage_charge_receivable",new BigDecimal("1240072").setScale(0,BigDecimal.ROUND_UP));
                rs.add(user32);
                rs.add(user31);
                rs.add(user33);
                break;
            default:
                throw new BusinessException("请输入正确参数");
        }
        return rs;
    }

    /**
     * 本年各水系污水费占比
     * @param req301204
     * @return
     */
    public Object getProportionOfSewageChargesByRiver(Req301204 req301204) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("river_name","磁湖水系");
        data1.put("rate","41%");
        data1.put("charge",new BigDecimal("901271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data1);

        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("river_name","花湖水系");
        data2.put("rate","36%");
        data2.put("charge",new BigDecimal("801271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data2);

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("river_name","新下陆水系");
        data3.put("rate","23%");
        data3.put("charge",new BigDecimal("503273").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data3);

        return rs;
    }

    /**
     * 本年各区域污水费占比
     * @param req301205
     * @return
     */
    public Object getProportionOfSewageChargesByRegion(Req301205 req301205) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("region_name","铁山区");
        data3.put("rate","23%");
        data3.put("charge",new BigDecimal("503273").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data3);

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("region_name","黄石港区");
        data1.put("rate","41%");
        data1.put("charge",new BigDecimal("901271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data1);

        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("region_name","黄金山区");
        data2.put("rate","36%");
        data2.put("charge",new BigDecimal("801271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data2);

        return rs;
    }

    /**
     * 年度用水性质占比
     * @param req301206
     * @return
     */
    public Object getProportionByNature(Req301206 req301206) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();

        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("water_nature","居民生活");
        data2.put("rate","36%");
        data2.put("charge",new BigDecimal("801271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data2);

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("water_nature","工业用水");
        data1.put("rate","41%");
        data1.put("charge",new BigDecimal("901271").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data1);

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("water_nature","特种行业");
        data3.put("rate","23%");
        data3.put("charge",new BigDecimal("503273").setScale(0,BigDecimal.ROUND_UP));
        rs.add(data3);

        return rs;
    }

    /**
     * 年度社区用水量排行
     * @param req301207
     * @return
     */
    public Object getWaterConsumptionByCommunity(Req301207 req301207) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();
        //需要按用水量排序
        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("community_name","大码头社区");
        data2.put("water_consumption","985282");
        rs.add(data2);

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("community_name","新闸社区");
        data1.put("water_consumption","53445");
        rs.add(data1);

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("community_name","新闸社区");
        data3.put("water_consumption","21445");
        rs.add(data3);

        return rs;
    }

    /**
     * 年度水系污水费统计
     * @param req301208
     * @return
     */
    public Object getYearProportionByWaterSystem(Req301208 req301208) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("water_system_name","磁湖水系");
        data1.put("receivable_water_fee","755484.10");
        data1.put("recepts_water_fee","694854.64");
        data1.put("rate","75%");
        rs.add(data1);

        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("water_system_name","黄金山水系");
        data2.put("receivable_water_fee","85499.00");
        data2.put("recepts_water_fee","74654.64");
        data2.put("rate","78%");
        rs.add(data2);

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("water_system_name","铁山湖水系");
        data3.put("receivable_water_fee","65254.10");
        data3.put("recepts_water_fee","56455.64");
        data3.put("rate","83%");
        rs.add(data3);

        return rs;
    }

    public Object getArrearsProportion(Req301209 req301209) {
        ArrayList<HashMap<String, Object>> rs = new ArrayList<>();

        HashMap<String, Object> data1 = new HashMap<>();
        data1.put("water_system_name","磁湖水系");
        data1.put("arrears_water_fee","694854.64");
        rs.add(data1);

        HashMap<String, Object> data2 = new HashMap<>();
        data2.put("water_system_name","黄金山水系");
        data2.put("arrears_water_fee","74654.64");
        rs.add(data2);

        HashMap<String, Object> data3 = new HashMap<>();
        data3.put("water_system_name","铁山湖水系");
        data3.put("arrears_water_fee","56455.64");
        rs.add(data3);



        HashMap<String, Object> all = new HashMap<>();
        all.put("list",rs);
        all.put("total","825964.92");
        return all;
    }
}
